﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ViewRidgeAssistant
{
    public partial class gui_settings : Form
    {

        private main _parent;
        public gui_settings(main parent)
        {
            InitializeComponent();
            this._parent = parent;

            this.setSettingsObjects();
        }

        private void setSettingsObjects()
        {
            //reading customer settings data
            this.cb_ID.Checked = Program.user_set._customer._id;
            this.cb_Name.Checked = Program.user_set._customer._name;
            this.cb_street.Checked = Program.user_set._customer._street;
            this.cb_city.Checked = Program.user_set._customer._city;
            this.cb_state.Checked = Program.user_set._customer._state;
            this.cb_zpcode.Checked = Program.user_set._customer._zip;
            this.cb_country.Checked = Program.user_set._customer._country;
            this.cb_email.Checked = Program.user_set._customer._email;
            this.cb_areacode.Checked = Program.user_set._customer._area_code;
            this.cb_phnumber.Checked = Program.user_set._customer._local_number;

            //reading artist settings data
            this.cb_ID_art.Checked = Program.user_set._artist._id;
            this.cb_name_art.Checked = Program.user_set._artist._artist_name;
            this.cb_bd_art.Checked = Program.user_set._artist._birth_date;
            this.cb_dd_art.Checked = Program.user_set._artist._deceased_date;
            this.cb_nat_art.Checked = Program.user_set._artist._nationality;

            //reading work settings data
            this.cb_ID_work.Checked = Program.user_set._work._id;
            this.cb_title_work.Checked = Program.user_set._work._title;
            this.cb_artID_work.Checked = Program.user_set._work._artist_id;
            this.cb_copy_work.Checked = Program.user_set._work._copy;
            this.cb_artist_name_work.Checked = Program.user_set._work._artist_name;

            //reading transaction settings data
            this.cb_ID_trans.Checked = Program.user_set._transaction._id;
            this.cb_workID_trans.Checked = Program.user_set._transaction._work_id;
            this.cb_dacq_trans.Checked = Program.user_set._transaction._date_acq;
            this.cb_acqpr_trans.Checked = Program.user_set._transaction._acq_price;
            this.cb_purdate_trans.Checked = Program.user_set._transaction._pur_date;
            this.cb_slprice_trans.Checked = Program.user_set._transaction._sales_price;
            this.cb_askpr_trans.Checked = Program.user_set._transaction._ask_price;
            this.cb_custID_trans.Checked = Program.user_set._transaction._customer_id;

            this.cb_name_trans.Checked = Program.user_set._transaction._customer_name;
            this.cb_phone_trans.Checked = Program.user_set._transaction._customer_phone;
            this.cb_title_trans.Checked = Program.user_set._transaction._work_title;
            this.cb_copy_trans.Checked = Program.user_set._transaction._work_copy;
        }

        private void b_apply_Click(object sender, EventArgs e)
        {
            //Apply settings for customer object;
            Program.user_set.setCustomerSettings(this.cb_ID.Checked,
                                                            this.cb_Name.Checked,
                                                            this.cb_areacode.Checked,
                                                            this.cb_phnumber.Checked,
                                                            this.cb_street.Checked,
                                                            this.cb_city.Checked,
                                                            this.cb_state.Checked,
                                                            this.cb_zpcode.Checked,
                                                            this.cb_country.Checked,
                                                            this.cb_email.Checked);
            //Apply settings from artist object;
            Program.user_set.setArtistSettings(this.cb_ID_art.Checked,
                                                        this.cb_nat_art.Checked,
                                                        this.cb_bd_art.Checked,
                                                        this.cb_dd_art.Checked,
                                                        this.cb_name_art.Checked);

            Program.user_set.setTransactionSettings(this.cb_ID_trans.Checked,
                                                                    this.cb_workID_trans.Checked,
                                                                    this.cb_dacq_trans.Checked,
                                                                    this.cb_acqpr_trans.Checked,
                                                                    this.cb_purdate_trans.Checked,
                                                                    this.cb_slprice_trans.Checked,
                                                                    this.cb_askpr_trans.Checked,
                                                                    this.cb_custID_trans.Checked,
                                                                    this.cb_title_trans.Checked,
                                                                    this.cb_copy_trans.Checked,
                                                                    this.cb_name_trans.Checked,
                                                                    this.cb_phone_trans.Checked);
            Program.user_set.setWorkSettings(this.cb_ID_work.Checked,
                                                    this.cb_artID_work.Checked,
                                                    this.cb_copy_work.Checked,
                                                    this.cb_title_work.Checked,
                                                    this.cb_desc_work.Checked,
                                                    this.cb_artist_name_work.Checked);
            
            this._parent.Enabled = true;
            this.Dispose();
        }

        private void b_abolition_Click(object sender, EventArgs e)
        {
            this._parent.Enabled = true;
            this.Dispose();
        }

        private void Close(object sender, FormClosedEventArgs e)
        {
            this._parent.Enabled = true;
            this.Dispose();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void tb_artists_Click(object sender, EventArgs e)
        {

        }
    }
}
